<template>
  <h1>小黑记事本</h1>
  <div class="inputbox">
    <input
      @keyup.enter="chengeInfo()"
      type="text"
      placeholder="请输入任务"
      v-model.trim="info"
    />
    <button @click="chengeInfo()">添加任务</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
let info = ref("");

defineProps(["info"]);

const emit = defineEmits(["add"]);

const chengeInfo = () => {
  if (info.value === "") {
    alert("输入的内容不能为空！");
    return;
  }
  emit("add", info);
  info.value = "";
};
</script>

<style></style>
